package com.app.mymusic.ui.persons;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.app.mymusic.R;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;

public class PersonsActivity extends AppCompatActivity {

    @BindView(R.id.person_rv)
    RecyclerView personRv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_persons);
        ButterKnife.bind(this);
        ArrayList<MultiItemEntity> list=initDatas();
        ExpandableItemAdapter adapter=new ExpandableItemAdapter(list);
        LinearLayoutManager manager=new LinearLayoutManager(this);
        personRv.setLayoutManager(manager);
        personRv.setAdapter(adapter);
    }

    private ArrayList<MultiItemEntity> initDatas() {
        int departCount=8;
        int personCount=5;
        ArrayList<MultiItemEntity> res = new ArrayList<>();
        for(int i=0;i<departCount;i++){
            Depart depart=new Depart("在岗"+i,"处室"+i);
            for(int j=0;j<personCount;j++){
                Person person=new Person("篮球"+j,"同学"+j);
                depart.addSubItem(person);
            }
            res.add(depart);
        }
        return res;
    }
}
